<?php
if(!defined('DEDEINC'))
{
    exit("Request Error!");
}

/**
 * 最新下载动态调用标签 柒码网络
 *
 */
 
 
function lib_newdowlist(&$ctag, &$refObj) //注：lib_newdowlist 的 'newdowlist' 为标签名称
{
    global $dsql,$sqlCt;
    $attlist="row|6"; //默认调用条数
    FillAttsDefault($ctag->CAttribute->Items,$attlist);
    extract($ctag->CAttribute->Items, EXTR_SKIP);

    $revalue = '';
    $innerText = trim($ctag->GetInnerText());
    if(empty($innerText)) $innerText = GetSysTemplets('memberlist.htm');

    $wheresql = " WHERE op.arcid > 0 AND op.product='archive'";
    $sql = "SELECT op.*,ms.*,addon.* FROM `#@__member_operation` op
        LEFT JOIN `#@__archives` ms ON ms.id = op.arcid
		LEFT JOIN `#@__addonsoft` addon ON addon.aid = op.arcid
        $wheresql order by op.mtime DESC LIMIT 0,$row ";
    
    $ctp = new DedeTagParse();
    $ctp->SetNameSpace('field','[',']');
    $ctp->LoadSource($innerText);

    $dsql->Execute('op',$sql);
    while($row = $dsql->GetArray('op'))
    {
        if($row['litpic']==''){
            $row['litpic'] = $GLOBALS['cfg_cmsurl'].'/images/defaultpic.gif';
        }
		if($row['title']==''){
            $row['title'] = '无标题';
        }
		if($row['resolution']==''){
            $row['resolution'] = '0';
        }
		if($row['dows']==''){
            $row['dows'] = '0';
        }
		if($row['id']!=''){
            $row['arcurl'] = $GLOBALS['cfg_phpurl'].'/view.php?aid='.$row['id'];
        }else{
			$row['arcurl'] = "javascript:alert('无链接');";
		}
        foreach($ctp->CTags as $tagid=>$ctag){
            if(isset($row[$ctag->GetName()])){ $ctp->Assign($tagid,$row[$ctag->GetName()]); }
        }
        $revalue .= $ctp->GetResult();
    }
    
    return $revalue;
}